package com.firefighting.util;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;

public class CreatePDFJuge {
	public static boolean CreatPdfJuge(String contractid,String start_time,String end_time,int type) throws SQLException{
	    Statement stmtzwy = DBUtil.getConnection().createStatement();
	    ArrayList<String> status=new ArrayList<String>();
	    int rsset=0;
	    if(type==1){
	    	ResultSet rszwyjudge=stmtzwy.executeQuery("select status from task where maintenanceplan_id in (select id from maintenanceplan where plan_execute_time='"+end_time+"' and plan_type='"
	    			+type+"' and contract_id='"+contractid+"')");
			while(rszwyjudge.next()){
				rsset++;
				if(rszwyjudge.getString("status")==null){
					status.add("");
				}else{
					status.add(rszwyjudge.getString("status"));	
				}	
			}
	    }else{
	    	ResultSet rszwyjudge=stmtzwy.executeQuery("select status from task where maintenanceplan_id in (select id from maintenanceplan where plan_execute_time<='"
	    			+end_time+"' and plan_execute_time>='"+start_time+"' and plan_type<='"+type+"' and contract_id='"+contractid+"')");
			while(rszwyjudge.next()){
				rsset++;
				if(rszwyjudge.getString("status")==null){
					status.add("");
				}else{
					status.add(rszwyjudge.getString("status"));	
				}		
			}
	    }
	    int count=0;
	    for(int x=0;x<status.size();x++){
	    	if(status.get(x).equals("审核通过")){
	    	}else{count++;}   	
	    }
	    if(count==0&&rsset!=0){return true;}
	    else{return false;}	
	}
}
